﻿@{
    ViewBag.Title = "用户管理》表单页面";
    Layout = "~/Views/Shared/_LayoutForm.cshtml";
}
<script type="text/javascript">
    $(function () {
        BindCombobox();
        InitControl();
        //判断新增的时候。如果选择了left项目，公司、部门会自动赋值
        if (!!GetQuery('CompanyId')) {
            //获取公司名称
            AjaxJson("/CommonModule/Company/SetForm", { KeyValue: GetQuery('CompanyId') }, function (data) {
                $("#CompanyId").val(data.CompanyId);
                $("#CompanyName").val(data.FullName);
            });
            //绑定部门
            BindDepartment(); $("#DepartmentId").val(GetQuery('DepartmentId'));
        }
    })
    //初始化绑定下拉框
    function BindCombobox() {
        //加载公司
        $("#CompanyName").focus(function () {
            var objId = this.id;
            comboBoxTree(objId, "150px");
            var itemtree = {
                onnodeclick: function (item) {
                    $("#CompanyId").val(item.id);
                    $('#CompanyName').val(item.text);
                    //加载部门
                    BindDepartment();
                },
                url: "@Url.Content("~/CommonModule/Company/TreeJson")"
            };
            $("#comboBoxTree" + objId).treeview(itemtree);
        })
        //工作性质
        BindDropItem("#WorkingProperty", "WorkingProperty", "==请选择==");
        //职务
        BindDropItem("#Duty", "Duty", "==请选择==");
        //学历
        BindDropItem("#Education", "Education", "==请选择==");
        //最高学位
        BindDropItem("#Degree", "Degree", "==请选择==");
        //职业资格
        BindDropItem("#Competency", "Professional", "==请选择==");

    }
    //部门下拉框
    function BindDepartment() {
        $("#DepartmentId").html("");
        $("#DepartmentId").append("<option value=''>==请选择==</option>");
        AjaxJson("/CommonModule/Department/ListJson", { CompanyId: $("#CompanyId").val() }, function (DataJson) {
            $.each(DataJson, function (i) {
                $("#DepartmentId").append($("<option></option>").val(DataJson[i].departmentid).html(DataJson[i].fullname));
            });
        })
    }
    //得到一个对象实体
    function InitControl() {
        if (!!GetQuery('KeyValue')) {
            AjaxJson("/CommonModule/User/SetUserForm", { KeyValue: GetQuery('KeyValue') }, function (data) {
                SetWebControls(data);
                BindDepartment(); $("#DepartmentId").val(data.DepartmentId);
                $("#Password").val("******");
            });
        }
    }
    //保存事件
    function AcceptClick() {
        if (!CheckDataValid('#form1')) {
            return false;
        }
        Loading(true, "正在提交数据...");
        window.setTimeout(function () {
            var postData = GetWebControls("#form1");
            postData["BuildFormJson"] = JSON.stringify(GetWebControls("#CustomAttribute"));
            AjaxJson("/CommonModule/User/SubmitUserForm?KeyValue=" + GetQuery('KeyValue'), postData, function (data) {
                tipDialog(data.Message, 3, data.Code);
                top.frames[tabiframeId()].windowload();
                closeDialog();
            });
        }, 200);
    }
</script>
<form id="form1">
    <div id="message" style="display: none; padding: 1px; padding-bottom: 0px;"></div>
    <div class="bd" style="border-bottom: none; margin: 1px;">
        <div class="tipstitle_title settingtable bold bd todayInfoPanelTab rightPanelTitle_normal">
            <div class="tab_list_top" style="position: absolute">
                <div id="Tabbasic" class="tab_list bd actived" onclick="Tabchange('basic')">基本信息</div>
                <div id="Tabwork" class="tab_list bd " onclick="Tabchange('work')">工作相关</div>
                <div id="TabCustomAttribute" class="tab_list bd " onclick="Tabchange('CustomAttribute')">自定义属性</div>
            </div>
        </div>
    </div>
    <div class="ScrollBar" style="margin: 1px; overflow: hidden;">
        <!--基本信息-->
        <div id="basic" class="tabPanel">
            <table class="form">
                <tr>
                    <th class="formTitle">工号：</th>
                    <td class="formValue">
                        <input id="Code" onblur="FieldExist(this.id,'Base_User','UserId','工号')" type="text" class="txt required" datacol="yes" err="工号" checkexpession="NotNull" />
                    </td>
                    <th class="formTitle">姓名：</th>
                    <td class="formValue">
                        <input id="RealName" type="text" class="txt required" datacol="yes" err="真实" checkexpession="NotNull" />
                    </td>
                </tr>
                <tr>
                    <th class="formTitle">登录账户：</th>
                    <td class="formValue">
                        <input id="Account" type="text" class="txt required" datacol="yes" err="登录账户" checkexpession="NotNull" />
                    </td>
                    <th class="formTitle">登录密码：
                    </th>
                    <td class="formValue">
                        <input id="Password" type="Password" class="txt required" datacol="yes" err="登录密码" checkexpession="NotNull" />
                    </td>
                </tr>
                <tr>
                    <th class="formTitle">性别：</th>
                    <td class="formValue">
                        <select id="Gender" class="txtselect">
                            <option value="男">男</option>
                            <option value="女">女</option>
                        </select>
                    </td>
                    <th class="formTitle">出生日期：</th>
                    <td class="formValue">
                        <input id="Birthday" type="text" class="txt Wdate" onfocus="WdatePicker({maxDate:'%y-%M-%d'})" />
                    </td>
                </tr>
                <tr>
                    <th class="formTitle">联系手机：</th>
                    <td class="formValue">
                        <input id="Mobile" type="text" class="txt" datacol="yes" err="手机" checkexpession="MobileOrNull" />
                    </td>
                    <th class="formTitle">联系电话：</th>
                    <td class="formValue">
                        <input id="Telephone" type="text" class="txt" datacol="yes" err="电话" checkexpession="PhoneOrNull" />
                    </td>
                </tr>
                <tr>
                    <th class="formTitle">电子邮箱：</th>
                    <td class="formValue">
                        <input id="Email" type="text" class="txt" />
                    </td>
                    <th class="formTitle">QQ号码：</th>
                    <td class="formValue">
                        <input id="OICQ" type="text" class="txt" />
                    </td>
                </tr>
                <tr>
                    <th class="formTitle">所在公司：</th>
                    <td class="formValue">
                        <input id="CompanyId" type="hidden" />
                        <input id="CompanyName" type="text" class="txt icontree" datacol="yes" err="所在公司" checkexpession="NotNull" />
                    </td>
                    <th class="formTitle">所在部门：</th>
                    <td class="formValue">
                        <select id="DepartmentId" class="txtselect" datacol="yes" err="所在部门" checkexpession="NotNull">
                        </select>
                    </td>
                </tr>
                <tr>
                    <th class="formTitle"></th>
                    <td class="formValue" colspan="3">
                        <span class="item">
                            <input id="InnerUser" name="InnerUser" type="checkbox" checked="checked" style="vertical-align: middle;" />
                            <label for="InnerUser" style="vertical-align: middle;">内部员工</label>
                            &nbsp;&nbsp;
                        </span>
                        <span class="item">
                            <input id="Enabled" name="Enabled" type="checkbox" checked="checked" style="vertical-align: middle;" />
                            <label for="Enabled" style="vertical-align: middle;">有效</label>
                        </span>
                        <label style="vertical-align: middle; color: red;">注意：禁用该用户后，将不能登录。</label>
                    </td>
                </tr>
                <tr>
                    <th class="formTitle">说明：
                    </th>
                    <td class="formValue" colspan="3">
                        <textarea id="Remark" class="txtArea" rows="6"></textarea>
                    </td>
                </tr>
            </table>
        </div>
        <!--工作相关-->
        <div id="work" class="tabPanel" style="display: none;">
            <table class="form">
                <tr>
                    <th class="formTitle">工作性质：</th>
                    <td class="formValue">
                        <select id="WorkingProperty" class="txtselect">
                        </select>
                    </td>
                    <th class="formTitle">入职日期：</th>
                    <td class="formValue">
                        <input id="WorkingDate" type="text" class="txt Wdate" onfocus="WdatePicker()" />
                    </td>
                </tr>
                <tr>
                    <th class="formTitle">身份证号：</th>
                    <td class="formValue">
                        <input id="IDCard" type="text" class="txt" />
                    </td>
                    <th class="formTitle">担任职务：</th>
                    <td class="formValue">
                        <select id="Duty" class="txtselect">
                        </select>
                    </td>
                </tr>
                <tr>
                    <th class="formTitle">年龄：</th>
                    <td class="formValue">
                        <input id="Age" type="text" class="txt" datacol="yes" err="年龄" checkexpession="NumOrNull" onfocus="IsNumber(this.id)" />
                    </td>
                    <th class="formTitle">工资卡号：
                    </th>
                    <td class="formValue">
                        <input id="BankCode" type="text" class="txt" />
                    </td>
                </tr>
                <tr>
                    <th class="formTitle">短号：</th>
                    <td class="formValue">
                        <input id="OfficeCornet" type="text" class="txt" />
                    </td>
                    <th class="formTitle">办公电话：</th>
                    <td class="formValue">
                        <input id="OfficePhone" type="text" class="txt" />
                    </td>
                </tr>
                <tr>
                    <th class="formTitle">传真：</th>
                    <td class="formValue">
                        <input id="OfficeFax" type="text" class="txt" />
                    </td>
                    <th class="formTitle">邮编：</th>
                    <td class="formValue">
                        <input id="OfficeZipCode" type="text" class="txt" />
                    </td>
                </tr>
                <tr>
                    <th class="formTitle">办公地址：
                    </th>
                    <td class="formValue" colspan="3">
                        <input id="OfficeAddress" type="text" class="txt" />
                    </td>
                </tr>
                <tr>
                    <th class="formTitle">最高学历：</th>
                    <td class="formValue">
                        <select id="Education" class="txtselect">
                        </select>
                    </td>
                    <th class="formTitle">最高学位：</th>
                    <td class="formValue">
                        <select id="Degree" class="txtselect">
                        </select>
                    </td>
                </tr>
                <tr>
                    <th class="formTitle">所学专业：</th>
                    <td class="formValue">
                        <input id="Major" type="text" class="txt" />
                    </td>
                    <th class="formTitle">毕业院校：
                    </th>
                    <td class="formValue">
                        <input id="School" type="text" class="txt" />
                    </td>
                </tr>
                <tr>
                    <th class="formTitle">毕业时间：</th>
                    <td class="formValue">
                        <input id="GraduationDate" type="text" class="txt Wdate" onfocus="WdatePicker()" />
                    </td>
                    <th class="formTitle">职业资格：</th>
                    <td class="formValue">
                        <select id="Competency" class="txtselect">
                        </select>
                    </td>
                </tr>
                <tr>
                    <th class="formTitle">紧急联系：</th>
                    <td class="formValue">
                        <input id="EmergencyContact" type="text" class="txt" />
                    </td>
                    <th class="formTitle">在职：</th>
                    <td class="formValue">
                        <span class="item">
                            <input id="IsDimission" name="IsDimission" type="checkbox" checked="checked" style="vertical-align: middle;" />
                            <label for="IsDimission" style="vertical-align: middle;">在职</label>
                        </span>
                    </td>
                </tr>
            </table>
        </div>
        <!--自定义属性-->
        <div id="CustomAttribute" class="tabPanel" style="display: none;">
            @Html.Raw(@LeaRun.WebApp.BaseCommon.CreateBuildForm(2))
        </div>
    </div>

</form>
